package xyz.xuminghai.javafx_learn.scene.paint;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
 * 2023/7/31 10:53 星期一<br/>
 * LinearGradient类用线性颜色渐变图案填充形状。用户可以指定两种或多种渐变颜色，并且此 Paint 将在每种颜色之间提供插值。
 *
 * @author xuMingHai
 */
public class LinearGradientApp extends Application {

    private final BorderPane root = new BorderPane();

    public static void main(String[] args) {
        Application.launch(args);
    }


    @Override
    public void init() {
        Rectangle rectangle = new Rectangle(200.0, 100.0,
                new LinearGradient(0.0, 0.0, 100.0,
                        100.0, false, CycleMethod.NO_CYCLE,
                        new Stop(0.5, Color.TEAL),
                        new Stop(0.9, Color.CRIMSON),
                        new Stop(0.8, Color.DARKORCHID)));
        root.setCenter(rectangle);
    }

    public void start(Stage primaryStage) {
        primaryStage.setTitle(getClass().getSimpleName());
        Scene scene = new Scene(root, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
